﻿@{
    Layout = null;
}

@model System.Data.DataSet
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    @if (false)
    {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
     <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    @Html.DevExpress().GetStyleSheets(
                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.GridView }
)
    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)
<script>

    function Changed() {
        window.location.href = rootPath + '/TaxDataCompare/Index?FTableName=' + FTableName.GetValue();
    }

    function FocusedRow2(s, e) {
        var str = ASPxClientGridView.Cast(s).name;
        if (str == "gvEditing") {
            var a = ASPxClientGridView.Cast("gvEditing").GetFocusedRowIndex();
            if (a != -1) {
                ASPxClientGridView.Cast("gvEditing2").SetFocusedRowIndex(a);
            }
        }
        else {
            var a = ASPxClientGridView.Cast("gvEditing2").GetFocusedRowIndex();
            if (a != -1) {
                ASPxClientGridView.Cast("gvEditing").SetFocusedRowIndex(a);
            }
        }
    }

    function MenuTop_emClick(source, e) {
        switch (e.item.name) {
            case "btnAdd":
                {
                    //增加
                    form1.submit();
                    break;

                }


        }
    }
</script>
</head>
<body>
    @using (Html.BeginForm("TaxDataCompareSave", "TaxDataCompare", FormMethod.Post, new { id = "form1" }))
    {
 @Html.DevExpress().Menu(settings =>
   {
       settings.Name = "toolBarMenu";
       settings.ItemAutoWidth = false;
       settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
       settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
       settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
       settings.Items.Add(item =>
       {
           item.Name = "btnAdd";
           item.Text = "数据同步";
           item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");
       });

       settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
       settings.ItemLinkMode = ItemLinkMode.ContentBounds;
   }).GetHtml()
<table  width="100%" style=" height:40px">
<tr>
<td align="right" style=" width:50%">相关代码表</td>
<td align="left">
 @Html.DevExpress().ComboBox(settings =>
               {
                   settings.Name = "FTableName";
                   settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(120);
                   settings.Properties.TextField = "Name";
                   settings.Properties.ValueField = "FTableName";
                   settings.Properties.ClientSideEvents.SelectedIndexChanged = "Changed";
               }).BindList(ViewData["combList"]).Bind(ViewData["FTableName"]).GetHtml()
</td>
</tr>
<tr>
<td colspan="2" align="center">
       <font Color="red" > 注：只显示差异数据</font>
</td>
</tr>
</table>

@Html.DevExpress().Splitter(settings =>
{
    settings.Name = "ContentSplitter";
    settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
    settings.Height = System.Web.UI.WebControls.Unit.Percentage(100);
    settings.Styles.Pane.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
    settings.Styles.Pane.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
    settings.FullscreenMode = true;
    settings.Panes.Add(subpane =>
    {
        subpane.Name = "ContentLeft";
        subpane.PaneStyle.CssClass = "leftPane";
        subpane.ShowCollapseBackwardButton = DefaultBoolean.True;
        subpane.Size = System.Web.UI.WebControls.Unit.Percentage(50);
        subpane.PaneStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(1);
        subpane.ScrollBars = System.Web.UI.WebControls.ScrollBars.Auto;
        subpane.SetContent(() =>
        {

            if ((Model).Tables.Count > 0)
            {
                Html.DevExpress().GridView(
            settings2 =>
            {
                settings2.Name = "gvEditing";
                settings2.KeyFieldName = ViewData["KeyColumns"].ToString();
                settings2.CallbackRouteValues = new { Controller = "TaxDataCompare", Action = "SYDataPartial" };
                settings2.Width = System.Web.UI.WebControls.Unit.Percentage(100);

                if (ViewData["showDt"] != null)
                {
                    foreach (System.Data.DataColumn dc in (ViewData["showDt"] as System.Data.DataTable).Columns)
                    {
                        settings2.Columns.Add(column =>
                        {
                            column.FieldName = dc.ColumnName;
                            column.Caption = dc.Caption;
                            column.SetDataItemTemplateContent(c =>
                            {
                                if (DataBinder.Eval(c.DataItem, "type") == "Update")
                                {
                                    ViewContext.Writer.Write("<font Color='green' > " + DataBinder.Eval(c.DataItem, dc.ColumnName) + "</font> ");
                                }
                                else
                                {
                                    if (DataBinder.Eval(c.DataItem, dc.ColumnName) != DBNull.Value)
                                    {
                                        ViewContext.Writer.Write("<font Color='red' > " + DataBinder.Eval(c.DataItem, dc.ColumnName) + "</font> ");
                                    }
                                    else
                                    {
                                        ViewContext.Writer.Write("<font Color='red' >&nbsp</font> ");
                                    }
                                    //ViewContext.Writer.Write("<font Color='red' > " + DataBinder.Eval(c.DataItem, dc.ColumnName) + "</font> ");
                                }
                            });
                        });
                    }
                }
                else
                {
                    settings2.Columns.Add("操作", ViewData["KeyColumns"].ToString());
                }

                settings2.SettingsBehavior.AllowSort = false;
                settings2.SettingsBehavior.AllowDragDrop = false;
                settings2.SettingsBehavior.AllowSelectByRowClick = false;
                settings2.SettingsLoadingPanel.Text = "数据读取中...";
                settings2.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings2.SettingsBehavior.AllowFocusedRow = true;

                settings2.ClientSideEvents.FocusedRowChanged = "function(s,e){FocusedRow2(s,e)}";

                settings2.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;
                settings2.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                settings2.CommandColumn.Visible = false;

                settings2.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };
                settings2.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };

            }).Bind(Model.Tables[1]).GetHtml();

            }
        });

    });

    settings.Panes.Add(subpaneContent =>
         {
             subpaneContent.Separator.Visible = DefaultBoolean.True;
             subpaneContent.Name = "ContentCenter";
             subpaneContent.PaneStyle.CssClass = "contentPane";
             subpaneContent.Separator.SeparatorStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
             subpaneContent.Separator.SeparatorStyle.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
             subpaneContent.PaneStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
             subpaneContent.SetContent(() =>
             {
                 if ((Model).Tables.Count > 0)
                 {
                     Html.DevExpress().GridView(
           settings2 =>
           {
               settings2.Name = "gvEditing2";
               settings2.KeyFieldName = ViewData["KeyColumns"].ToString();
               settings2.CallbackRouteValues = new { Controller = "TaxDataCompare", Action = "SYDataPartial" };
               settings2.Width = System.Web.UI.WebControls.Unit.Percentage(100);
               if (ViewData["showDt"] != null)
               {
                   foreach (System.Data.DataColumn dc in (ViewData["showDt"] as System.Data.DataTable).Columns)
                   {
                       settings2.Columns.Add(column =>
                       {
                           column.FieldName = dc.ColumnName;
                           column.Caption = dc.Caption;
                           column.SetDataItemTemplateContent(c =>
                            {
                                if (DataBinder.Eval(c.DataItem, "type") == "Update")
                                {
                                    ViewContext.Writer.Write("<font Color='green' > " + DataBinder.Eval(c.DataItem, dc.ColumnName) + "</font> ");
                                }
                                else
                                {
                                    if (DataBinder.Eval(c.DataItem, dc.ColumnName) != DBNull.Value)
                                    {
                                        ViewContext.Writer.Write("<font Color='blue' > " + DataBinder.Eval(c.DataItem, dc.ColumnName) + "</font> ");
                                    }
                                    else
                                    {
                                        ViewContext.Writer.Write("<font Color='blue' >&nbsp</font> ");
                                    }

                                }
                            });
                       });
                   }
               }
               else
               {
                   settings2.Columns.Add("操作", ViewData["KeyColumns"].ToString());
               }

               settings2.SettingsBehavior.AllowSort = false;
               settings2.SettingsBehavior.AllowDragDrop = false;
               settings2.SettingsBehavior.AllowSelectByRowClick = false;
               settings2.SettingsLoadingPanel.Text = "数据读取中...";
               settings2.SettingsBehavior.AllowClientEventsOnLoad = false;
               settings2.SettingsBehavior.AllowFocusedRow = true;
               settings2.ClientSideEvents.FocusedRowChanged = "FocusedRow2";
               settings2.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;


               settings2.ClientSideEvents.BeginCallback = "function(s,e){FocusedRow2(s,e)}";
               settings2.CommandColumn.Visible = false;

               settings2.PageIndexChanged = (sender, e) =>
               {
                   ASPxGridView grid = (ASPxGridView)sender;
                   grid.Selection.UnselectAll();
               };
               settings2.DataBinding = (sender, e) =>
               {
                   ASPxGridView grid = (ASPxGridView)sender;
                   for (int i = 0; i < grid.AllColumns.Count; i++)
                   {
                       if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                       {
                           grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                       }
                       if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                       {
                           grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                       }
                   }
               };

           }).Bind(Model.Tables[0]).GetHtml();

                 }
             });

         });

}).GetHtml()
    }
</body>
</html>
